import { Validation } from '../models/validation';

export class ValidationUtil {
  static required(fieldName: string) {
    return [Validation.required(fieldName)];
  }

  static maxLength(length: number) {
    return [Validation.maxLength(length)];
  }

  static requiredAndMaxLength(fieldName: string, length: number) {
    return [...[Validation.required(fieldName)], ...[Validation.maxLength(length)]];
  }

  static requiredAndCustomized(fieldName: string, validator: Function) {
    return [...[Validation.required(fieldName)], ...[Validation.customizedValidator(validator)]];
  }

  static requiredAndMaxLengthAndCustomized(fieldName: string, length: number, validator: Function) {
    return [...this.requiredAndMaxLength(fieldName, length), ...[Validation.customizedValidator(validator)]];
  }
}

export default ValidationUtil;
